import React, { Component } from 'react';
import { connect } from 'dva';
import { Card, Badge, Table, Divider, Button } from 'antd';
import DescriptionList from '@/components/DescriptionList';
import PageHeaderWrapper from '@/components/PageHeaderWrapper';
import styles from './BasicProfile.less';
import router from 'umi/router';

const { Description } = DescriptionList;

/*@connect(({ restfulapi, loading }) => ({
  restfulapi,
  loading: loading.effects['restfulapi/get'],
}))*/

@connect(({restfulapi, loading }) => ({
  restfulapi,
  loading: loading.models.restfulapi,
}))

class BasicProfile extends Component {
  componentDidMount() {
    const { dispatch, match } = this.props;
    const { location: {query} } = this.props;

    dispatch({
      type: 'restfulapi/get',
      payload: query,
    });
  }

  handleReturnEvt() {
    router.push({
      pathname: '/dev/search-table',
    });
  };

  render() {
    const { restfulapi = {}, loading } = this.props;
    const { data = {} } = restfulapi;

    return (
      <PageHeaderWrapper title="基础详情页" loading={loading}>
        <Card bordered={false}>
          <DescriptionList size="large" title="账号信息" style={{ marginBottom: 32 }}>
            <Description term="ID">{data.id}</Description>
            <Description term="类型">{data.type}</Description>
            <Description term="用户名">{data.name}</Description>
          </DescriptionList>
          <Divider style={{ marginBottom: 32 }} />
          <DescriptionList size="large" title="用户信息" style={{ marginBottom: 32 }}>
            <Description term="性别">{data.sex}</Description>
            <Description term="出生日期">{data.birthday}</Description>
            <Description term="年龄">{data.age}</Description>
            <Description term="备注">{data.desc}</Description>
          </DescriptionList>
          <Divider style={{ marginBottom: 32 }} />
          <Button type="primary" style={{ marginRight: 8 }} onClick={()=>this.handleReturnEvt()}>返回</Button>
        </Card>
      </PageHeaderWrapper>
    );
  }
}

export default BasicProfile;
